package excel;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class TestMain {
	@RequestMapping(value ="/export",method = RequestMethod.GET)
	public String testExport(HttpServletResponse response) {
		System.out.println("begin");
		List<TestUser> list = new ArrayList<TestUser>();
		list.add(new TestUser("1", "张三", "男"));
		list.add(new TestUser("1", "张三", "男"));
		list.add(new TestUser("1", "张三", "男"));

		try {
			 String fileName = "用户数据.xlsx";
			 new ExportExcel("用户数据", TestUser.class).setDataList(list).write(response,fileName).dispose();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "index.jsp";

	}
}
